import { DateTransformer } from '../utils/dateTransformer';
import { Entity, Column, PrimaryGeneratedColumn, BaseEntity } from 'typeorm';
import { Exclude } from 'class-transformer';

@Entity('user')
export class UserEntity extends BaseEntity{
    // 将 int 类型的id转成string类型，防止前端精度缺失

    @PrimaryGeneratedColumn({type:'bigint'})
    id: string 

    @Column({width:20})
    username: string
 
    @Exclude()
    @Column({width:20})
    password: string

    @Column({ length: 20 })
    phone: string

    @Column({ comment: '微信小程序openId', default: '' })
    wxMiniOpenId: string

    @Column({ comment: '微信头像', default: '' })
    wxAvatarUrl: string

    @Column({ comment: '微信昵称', default: '' })
    wxNickname: string

    @Column({ comment: '0:未知，1:代表男 2：女', width: 1, default: 0 })
    sex: number

    @Column({ comment: '上次登录时间', type: 'datetime', nullable: true ,transformer: new DateTransformer()})
    lastLoginTime: string


}  